﻿using Prism.Events;
using Prism.Ioc;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Zhy.PrismDialog
{
    /// <summary>
    /// 主窗口类
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// 主窗口对象类
        /// </summary>
        /// <param name="containerProvider">用于解析对象的依赖项注入容器</param>
        /// <param name="eventAggregator">订阅消息事件的</param>
        public MainWindow(
             IContainerProvider containerProvider,
             IEventAggregator eventAggregator)
        {
            InitializeComponent();
            // MainViewModel依赖注入
            var vm = containerProvider.Resolve<MainViewModel>();
            // 业务类绑定
            this.DataContext = vm;
            // 消息订阅注册
            eventAggregator.GetEvent<OpenMessage>()
                .Subscribe(OnOpen);
        }

        /// <summary>
        /// 消息订阅事件
        /// </summary>
        /// <param name="arg"></param>
        private void OnOpen(string arg)
        {
            // 窗口的打开
            //new UCDetail().ShowDialog();
        }
    }
}